package com.spbdx.studyspringboot.duty_chain.temp;

import com.spbdx.studyspringboot.duty_chain.chain.IHandler;
import com.spbdx.studyspringboot.duty_chain.chain.ProductActivityHandler;
import com.spbdx.studyspringboot.duty_chain.chain.ProductBaseInfoHandler;
import com.spbdx.studyspringboot.duty_chain.chain.ProductSKUHandler;
import com.spbdx.studyspringboot.duty_chain.entity.Product;

/**
 * @Author: fan
 * @CreateTime 2025/1/1 21:44
 * @Description 责任链工厂
 * @Version 1.0
 */
public class ProductChainFactory {

    public static IHandler first;


    public ProductChainFactory(){

        ProductBaseInfoHandler baseInfoHandler = new ProductBaseInfoHandler();
        ProductActivityHandler activityHandler = new ProductActivityHandler();
        ProductSKUHandler skuHandler = new ProductSKUHandler();
        baseInfoHandler.setNext(activityHandler);
        activityHandler.setNext(skuHandler);
        first = baseInfoHandler;
    }

    /**
     * 执行具体业务场景中的责任链集合
     * @param product
     * @return
     */
//    public Boolean executeHandle(Product product){
//        return first.handle(product);
//    }

    public void executeHandle(Product product){
        first.handle(product);
    }
}
